﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using CoreModel = PlayerScannerCore.Model;
using Mvvm;
using PlayerScannerCore.Model;

namespace PlayerScannerCore.ViewModel
{
    public class ShieldViewModel : ItemViewModel, IShield
    {
        private int _def;
        private int _evp;
        private int _defBonus;
        private int _evpBonus;
        private int _equippableBy;
        private int _lvlReq;
        private int _efr;
        private int _eic;
        private int _eth;
        private int _edk;
        private int _elt;

        internal ShieldViewModel()
        {
            ItemType = ItemType.Shield;
        }

        internal override void Update(IItem item)
        {
            var shield = (IShield)item;

            Defense = shield.Defense;
            Evasion = shield.Evasion;
            DefenseBonus = shield.DefenseBonus;
            EvasionBonus = shield.EvasionBonus;
            EquippableBy = shield.EquippableBy;
            LevelRequirement = shield.LevelRequirement;
            Efr = shield.Efr;
            Eic = shield.Eic;
            Eth = shield.Eth;
            Edk = shield.Edk;
            Elt = shield.Elt;

            base.Update(shield);
        }

        public int Defense
        {
            get { return _def; }
            set
            {
                if (_def != value)
                {
                    _def = value;
                    OnPropertyChanged("Defense");
                }
            }
        }

        public int Evasion
        {
            get { return _evp; }
            set
            {
                if (_evp != value)
                {
                    _evp = value;
                    OnPropertyChanged("Evasion");
                }
            }
        }

        public int DefenseBonus
        {
            get { return _defBonus; }
            set
            {
                if (_defBonus != value)
                {
                    _defBonus = value;
                    OnPropertyChanged("DefenseBonus");
                }
            }
        }

        public int EvasionBonus
        {
            get { return _evpBonus; }
            set
            {
                if (_evpBonus != value)
                {
                    _evpBonus = value;
                    OnPropertyChanged("EvasionBonus");
                }
            }
        }

        public int EquippableBy
        {
            get { return _equippableBy; }
            set
            {
                if (_equippableBy != value)
                {
                    _equippableBy = value;
                    OnPropertyChanged("EquippableBy");
                }
            }
        }

        public int LevelRequirement
        {
            get { return _lvlReq; }
            set
            {
                if (_lvlReq != value)
                {
                    _lvlReq = value;
                    OnPropertyChanged("LevelRequirement");
                }
            }
        }

        public int Efr
        {
            get { return _efr; }
            set
            {
                if (_efr != value)
                {
                    _efr = value;
                    OnPropertyChanged("Efr");
                }
            }
        }

        public int Eic
        {
            get { return _eic; }
            set
            {
                if (_eic != value)
                {
                    _eic = value;
                    OnPropertyChanged("Eic");
                }
            }
        }

        public int Eth
        {
            get { return _eth; }
            set
            {
                if (_eth != value)
                {
                    _eth = value;
                    OnPropertyChanged("Eth");
                }
            }
        }

        public int Edk
        {
            get { return _edk; }
            set
            {
                if (_edk != value)
                {
                    _edk = value;
                    OnPropertyChanged("Edk");
                }
            }
        }

        public int Elt
        {
            get { return _elt; }
            set
            {
                if (_elt != value)
                {
                    _elt = value;
                    OnPropertyChanged("Elt");
                }
            }
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 23;
                hash = hash * 29 + Defense.GetHashCode();
                hash = hash * 29 + Evasion.GetHashCode();
                hash = hash * 29 + DefenseBonus.GetHashCode();
                hash = hash * 29 + EvasionBonus.GetHashCode();
                hash = hash * 29 + EquippableBy.GetHashCode();
                hash = hash * 29 + LevelRequirement.GetHashCode();
                hash = hash * 29 + Efr.GetHashCode();
                hash = hash * 29 + Eic.GetHashCode();
                hash = hash * 29 + Eth.GetHashCode();
                hash = hash * 29 + Edk.GetHashCode();
                hash = hash * 29 + Elt.GetHashCode();
                return hash * 29 + base.GetHashCode();
            }
        }

        public override bool Equals(object obj)
        {
            var objAsSpecific = obj as ShieldViewModel;

            if (objAsSpecific == null)
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            return objAsSpecific.Defense == Defense
                && objAsSpecific.Evasion == Evasion
                && objAsSpecific.DefenseBonus == DefenseBonus
                && objAsSpecific.EvasionBonus == EvasionBonus
                && objAsSpecific.EquippableBy == EquippableBy
                && objAsSpecific.LevelRequirement == LevelRequirement
                && objAsSpecific.Efr == Efr
                && objAsSpecific.Eic == Eic
                && objAsSpecific.Eth == Eth
                && objAsSpecific.Edk == Edk
                && objAsSpecific.Elt == Elt
                && base.Equals(obj);
        }
    }
}
